<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<meta content="PerformanceTest,com.gskinner.utils.PerformanceTest,logger,out,getInstance,testFunction,testRender,testSuite" name="keywords">
<title>com.gskinner.utils.PerformanceTest</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="asdoc.js"></script><script type="text/javascript" language="javascript" src="cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'PerformanceTest - API Documentation';
				var baseRef = '';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<!--<tr>
<td align="left" class="titleTableTitle">API Documentation</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('all-classes.html')" href="package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('all-classes.html')" href="class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('index-list.html')" href="all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="index.html?com/gskinner/utils/PerformanceTest.html&amp;com/gskinner/utils/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="images/logo.jpg"></td>
</tr>-->
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Class&nbsp;PerformanceTest</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#propertySummary">Properties</a>&nbsp;| <a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Class PerformanceTest"); titleBar_setSubNav(false,true,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">com.gskinner.utils</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Class</td><td class="classSignature">public class PerformanceTest</td>
</tr>
</table>
<p></p>
 This class represents a first attempt at creating a simple, but powerful performance testing harness for
 ActionScript 3. Its most important feature is testing and reporting on simple to write test suite classes.
 This is useful both for testing language features (ex. which loop structure runs fastest, what are the
 performance advantages of Vectors over Arrays), and for creating frameworks for testing the performance of
 projects as they are developed.<br/>
 <br/>
 PerformanceTest instances maintain a queue, and will run multiple tests in order. Each method that is tested
 will be run asynchronously (iterations of the method test are run synchronously), and the garbage collector
 is run in between each method test to provide better isolated results.
 <p></p>
<br>
<hr>
</div>
<a name="propertySummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Properties</div>
<table id="summaryTableProperty" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Property</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#logger">logger</a> : Object<div class="summaryTableDescription">
  Specifies an object to handle logging results as they are generated.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#out">out</a> : Function<div class="summaryTableDescription">
  Specifies a function to handle the text output from the default logging.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
</table>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#PerformanceTest()">PerformanceTest</a>()</div>
<div class="summaryTableDescription"></div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#getInstance()">getInstance</a>():<a href="../utils/PerformanceTest.html">PerformanceTest</a>
</div>
<div class="summaryTableDescription">[static]
  This is a convenience function to allow you to access a single instance of PerformanceTest globally, so that
  you have a single test queue.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#testFunction()">testFunction</a>(testFunction:Function, iterations:uint = 1, name:String = "Function", description:String = null):void</div>
<div class="summaryTableDescription">
  Allows you to test the performance of a single function.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#testRender()">testRender</a>(displayObject:DisplayObject, bounds:Rectangle = null, iterations:uint = 1, name:String = "Render", description:String = null):void</div>
<div class="summaryTableDescription">
  This method allows you to test the time it takes to render a complex display object.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#testSuite()">testSuite</a>(testSuite:Object, methods:Array = null, iterations:uint = 0, name:String = null, description:String = null):void</div>
<div class="summaryTableDescription">
  Tests a suite of methods.</div>
</td><td class="summaryTableOwnerCol">PerformanceTest</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="propertyDetail"></a>
<div class="detailSectionHeader">Property detail</div>
<a name="logger"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">logger</td><td class="detailHeaderType">property</td>
</tr>
</table>
<div class="detailBody">
<code>public var logger:Object</code><p>
  Specifies an object to handle logging results as they are generated. This allows you to bypass the
  default text logging output, in order to store, chart or display the output differently. The logger object
  must expose 4 methods:<br/>
  <br/>
  <code>logBegin(name:String,description:String,iterations:uint)</code><br/>
  Called when a new test begins.<br/>
  <br/>
  <code>logError(name:String,details:Error)</code><br/>
  Called if an error occurs while testing a method. The details parameter will be null if the
  method was not found in the test suite, or will error object that was generated if an error
  occured while running the method.<br/>
  <br/>
  <code>logMethod(name:String, time:uint, iterations:uint, details:</code><br/>
  Called after a method was tested successfully. The time parameter will be passed the total
  time for all iterations, calculate average with <code>time/iterations</code>. Currently, the
  the details parameter is only passed a value for "tare" methods - the number of times the tare
  method was run before returning consistent timing.<br/>
  <br/>
  <code>logEnd(name:String)</code>
  Called when a test ends.
  </p></div>
<a name="out"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">out</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public var out:Function</code><p>
  Specifies a function to handle the text output from the default logging. You could use this
  to write the default output to a file, or display it in a text field. For example
  setting <code>myPerformanceTest.out = trace;</code> will cause the log output to be traced.
  </p></div>
<a name="constructorDetail"></a>
<div class="detailSectionHeader">Constructor detail</div>
<a name="PerformanceTest()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">PerformanceTest</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">constructor</td>
</tr>
</table>
<div class="detailBody">
<code>public function PerformanceTest()</code>
</div>
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="getInstance()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">getInstance</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public static function getInstance():<a href="../utils/PerformanceTest.html">PerformanceTest</a></code><p>
  This is a convenience function to allow you to access a single instance of PerformanceTest globally, so that
  you have a single test queue.
  </p><p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code><a href="../utils/PerformanceTest.html">PerformanceTest</a></code></td>
</tr>
</table>
</div>
<a name="testFunction()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">testFunction</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function testFunction(testFunction:Function, iterations:uint = 1, name:String = "Function", description:String = null):void</code><p>
  Allows you to test the performance of a single function. Handy for testing functions on the timeline.
  </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">testFunction</span>:Function</code> &mdash; The function to test.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">iterations</span>:uint</code> (default = <code>1</code>)<code></code> &mdash; The number of times to run the function. More iterations will take longer to run, but will result in a more consistent result.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">name</span>:String</code> (default = "<code>Function</code>")<code></code> &mdash; The name to use when logging this test.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">description</span>:String</code> (default = <code>null</code>)<code></code> &mdash; The description to use when logging this test.
  </td>
</tr>
</table>
</div>
<a name="testRender()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">testRender</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function testRender(displayObject:DisplayObject, bounds:Rectangle = null, iterations:uint = 1, name:String = "Render", description:String = null):void</code><p>
  This method allows you to test the time it takes to render a complex display object. This is a largely untested feature in this version of PerformanceSuite.
  </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">displayObject</span>:DisplayObject</code> &mdash; A DisplayObject to test rendering times for. For example you could test the render time of a display object with complex vectors or filters.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">bounds</span>:Rectangle</code> (default = <code>null</code>)<code></code> &mdash; Specifies the area of the display object to render. For example, you might want to limit the render to the area that would be visible on the stage at runtime. If bounds is not specified, it will use the bounds of the display object.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">iterations</span>:uint</code> (default = <code>1</code>)<code></code> &mdash; The number of times to run the render. More iterations will take longer to run, but will result in a more consistent result.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">name</span>:String</code> (default = "<code>Render</code>")<code></code> &mdash; The name to use when logging this test.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">description</span>:String</code> (default = <code>null</code>)<code></code> &mdash; The description to use when logging this test.
  </td>
</tr>
</table>
</div>
<a name="testSuite()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">testSuite</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function testSuite(testSuite:Object, methods:Array = null, iterations:uint = 0, name:String = null, description:String = null):void</code><p>
  Tests a suite of methods. The suite can be any class instance with public methods. The suite object can optionally
  expose <code>name</code>, <code>description</code>, and <code>methods</code> properties that will be used if the
  corresponding parameters are not specified. The suite can also expose a <code>tare</code> method (see below for info).<br/>
  <br/>
  A test suite should group similar tests together (ex. testing different loop structures), and each test method should
  run for a significant amount of time (because testing methods that run for only a few ms is unreliable). You can use
  a loop inside of your test methods to make simple operations run longer.<br/>
  <br/>
  Similar to unit testing, you can write test suites alongside your main project files, and have the test suite methods
  call methods in your project to test them. In this way you can create an evolving performance testing framework
  without having to modify your project source code.<br/>
  <br/>
  <b>See the samples for more information on writing test suites.</b><br/>
  <br/>
  <b>Tare methods</b><br/>
  If a test suite exposes a public method called tare, it will be run repeatedly (up to 6 times) at the beginning of
  the suite until it returns a consistent timing result. That time will then be subtracted from the results of all other tests.
  This is useful for accounting for "infrastructure costs".<br/>
  <br/>
  For example, if you have a suite of tests to test mathematical
  operations, and every test has a loop to repeat the operation 100000 times (to get measureable results), you could write
  a tare method that contains an empty loop that repeats 100000 times, to eliminate the time required to run the loop from your results.
  </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">testSuite</span>:Object</code> &mdash; The test suite instance to test.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">methods</span>:Array</code> (default = <code>null</code>)<code></code> &mdash; An array of method names to test. If null, the testSuite will be introspected, and all of its public methods will be tested (except those whose names begin with an underscore).
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">iterations</span>:uint</code> (default = <code>0</code>)<code></code> &mdash; The number of times to run each method. More iterations will take longer to run, but will result in a more consistent result.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">name</span>:String</code> (default = <code>null</code>)<code></code> &mdash; The name to use when logging this test.
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">description</span>:String</code> (default = <code>null</code>)<code></code> &mdash; The description to use when logging this test.
  </td>
</tr>
</table>
</div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright"> 
</center>
</div>
</body>
</html>
<!-- -->
